package com.yksj.healthtalk.ui.doctorstation;

import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.MediaController;
import android.widget.VideoView;

import com.yksj.healthtalk.comm.BaseFragmentActivity;
import com.yksj.healthtalk.media.CustomVideoView;
import com.yksj.healthtalk.ui.R;

public class MediaPlayActivity extends BaseFragmentActivity implements OnClickListener {
	
	CustomVideoView mVideoView;
	String mVideoPath;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.media_play_layout);
		mVideoPath = getIntent().getStringExtra("path");
		
		iniUI();
	}
	
	private void iniUI(){
		initTitle();
		titleTextV.setText(getIntent().getStringExtra("title"));
		setBackBtn("返回", this);
		MediaController controller = new MediaController(this);
		mVideoView = (CustomVideoView)findViewById(R.id.videoView1);
		mVideoView.setMediaController(controller);
		mVideoView.setVideoPath(mVideoPath);
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.title_back:
			onBackPressed();
			break;
		}
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		if(mVideoView != null)
			mVideoView.resume();
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		if(mVideoView != null){
			mVideoView.stopPlayback();
			mVideoView = null;
		}
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		if(mVideoView.isPlaying()){
			mVideoView.pause();
		}
	}
}
